using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage; 

namespace marbletrack
{
    class Menu
    {
         public List<Buttons> submenus;
        
        int screenWidth;
        Texture2D menuBackground;
        public Saver saver = new Saver();
        const int NUMBEROFBUTTONS = 4;
        const int BUTTONSIZE = 100;

        public Menu(GraphicsDeviceManager Graphics)
        {
            screenWidth = Convert.ToInt32(Graphics.GraphicsDevice.Viewport.Width);
            
            submenus = new List<Buttons>();
            menuBackground = marbletrack.Game1.contentloader.Load<Texture2D>("Textures\\WhiteSquare");
            
            int buttonSpacing = (Graphics.GraphicsDevice.Viewport.Width - NUMBEROFBUTTONS * BUTTONSIZE) / (NUMBEROFBUTTONS);

            submenus.Add(new Buttons(Game1.contentloader.Load<Texture2D>("Textures//Button Texture//NewGame"), new Rectangle(buttonSpacing/2, 0, BUTTONSIZE, BUTTONSIZE), new Buttons.buttonClicked(Game1.Reset)));
            //submenus.Add(new Buttons(Game1.contentloader.Load<Texture2D>("Textures//Button Texture//Save"), new Rectangle(buttonSpacing*2 + BUTTONSIZE, 0, BUTTONSIZE, BUTTONSIZE), new Buttons.buttonClicked(saver.Save), new Buttons.mouseOver(Buttons.DoNothing)));
            //submenus.Add(new Buttons(Game1.contentloader.Load<Texture2D>("Textures//Button Texture//Load"), new Rectangle(buttonSpacing * 3 + BUTTONSIZE*2, 0, BUTTONSIZE, BUTTONSIZE), new Buttons.buttonClicked(saver.Load), new Buttons.mouseOver(Buttons.DoNothing)));
            submenus.Add(new Buttons(Game1.contentloader.Load<Texture2D>("Textures//Button Texture//SmilieAtBottem"), new Rectangle(buttonSpacing * 3/2 + BUTTONSIZE * 1, 0, BUTTONSIZE, BUTTONSIZE), new Buttons.buttonClicked(Game1.AddBallToList)));
            submenus.Add(new Buttons(Game1.contentloader.Load<Texture2D>("Textures//Button Texture//BallAdd"), new Rectangle(buttonSpacing * 5/2 + BUTTONSIZE*2, 0, BUTTONSIZE, BUTTONSIZE), new Buttons.buttonClicked(Game1.AddBallToList)));
            submenus.Add(new Buttons(Game1.contentloader.Load<Texture2D>("Textures//Button Texture//Quit"), new Rectangle(buttonSpacing * 7/2 + BUTTONSIZE*3, 0, BUTTONSIZE, BUTTONSIZE), new Buttons.buttonClicked(Game1.AddBallToList)));
            
            foreach (Buttons but in submenus)
            {
                but.normalColor = Color.White;
                but.highlightColor = Color.Wheat;
            }
        }
        public void Draw()
        {
            foreach (Buttons button in submenus)
            {
                button.Draw();
            }
            Game1.Graphics.GraphicsDevice.RenderState.DepthBufferEnable = true;
        }
        public void Update()
        {
            foreach (Buttons button in submenus)
            {
                button.Update();
            }
        }
        
        
    }
}
